<template>
	<view class="container">
		<view v-for="(item, index) in list" class="infoList" @click="openPopup(item)" v-if="list.length>0">
			<view class="box">
				<view class="name">
					{{item.userName}}
				</view>
				<view class="time">
					{{item.inspectionTime}}
				</view>
			</view>
		</view>
		<view v-if="list.length==0" style="height: 300rpx;">
			<nullVue></nullVue>
		</view>
		<!-- 新增-->
		<view class="addForm">
			<button @click="add">{{ app.language.wytj}}</button>
		</view>
		<!-- 详情弹框 -->
		<uni-popup ref="popup" type="bottom">
		  <view class="popup-content">
			<!-- 自定义内容 -->
			<!-- <text>这是一个底部弹窗</text>
			<button @click="closePopup">关闭</button> -->
			<!-- 体温 -->
			<view class="box">
				<view class="boxL">{{ app.language.jbjk_bodyTemperature }}:{{datainfo.bodyTemperature}}</view>
				<view class="boxR" v-if="datainfo.inspectionzt==app.language.hg">{{datainfo.inspectionzt}}</view>
				<view class="boxR1" v-if="datainfo.inspectionzt==app.language.bhg">{{datainfo.inspectionzt}}</view>
			</view>
			<!-- 心率 -->
			<view class="box">
				<view>{{ app.language.jbjk_heartRate }}:{{datainfo.heartRate}}</view>
				<view class="boxR" v-if="datainfo.heartRatezt==app.language.hg">{{datainfo.heartRatezt}}</view>
				<view class="boxR1" v-if="datainfo.heartRatezt==app.language.bhg">{{datainfo.heartRatezt}}</view>
			</view>
			<!-- 血氧饱和度 -->
			<view class="box">
				<view>{{ app.language.jbjk_bloodOxygenSaturation }}:{{datainfo.bloodOxygenSaturation}}</view>
				<view class="boxR" v-if="datainfo.bloodOxygenSaturationzt==app.language.hg">{{item.bloodOxygenSaturationzt}}</view>
				<view class="boxR1" v-if="datainfo.bloodOxygenSaturationzt==app.language.bhg">{{datainfo.bloodOxygenSaturationzt}}</view>
			</view>
			<!-- 高压 -->
			<view class="box">
				<view>{{ app.language.jbjk_bloodPressure }}:{{datainfo.bloodPressure}}</view>
				<view class="boxR" v-if="datainfo.bloodPressurezt==app.language.hg">{{datainfo.bloodPressurezt}}</view>
				<view class="boxR1" v-if="datainfo.bloodPressurezt==app.language.bhg">{{datainfo.bloodPressurezt}}</view>
			</view>
			<!-- 低压 -->
			<view class="box">
				<view>{{ app.language.jbjk_bloodPressured }}:{{datainfo.dycount}}</view>
				<view class="boxR" v-if="datainfo.dycountzt==app.language.hg">{{datainfo.dycountzt}}</view>
				<view class="boxR1" v-if="datainfo.dycountzt==app.language.bhg">{{datainfo.dycountzt}}</view>
			</view>
			<!-- 尿酸 -->
			<view class="box">
				<view>{{ app.language.rcjk_uricAcid }}:{{datainfo.uricAcid}}</view>
			</view>
			<!-- 血糖 -->
			<view class="box">
				<view>{{ app.language.rcjk_bloodSugar }}:{{datainfo.bloodSugar}}</view>
				<view class="boxR" v-if="datainfo.bloodSugarzt==app.language.hg">{{datainfo.bloodSugarzt}}</view>
				<view class="boxR1" v-if="datainfo.bloodSugarzt==app.language.bhg">{{datainfo.bloodSugarzt}}</view>
			</view>
			<!-- 其他 -->
			<view class="box" v-if="datainfo.other">
				<view>{{ app.language.rcjk_other }}:{{datainfo.other}}</view>
			</view>
		  </view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		getRcjk
	} from '@/api/user.js'
	import nullVue from '@/components/null';
	const global = getApp().globalData;
	export default {
		components: {
			nullVue
		},
		data() {
			return {
				app: {
					global: global,
					name: global.appName,
					language: global.language
				},
				list: [],
				token: "",
				hrUuid: "",
				userInfo: {},
				datainfo:{}
			}
		},
		onLoad() {
			this.getToken()
			setTimeout(() => {
				this.getList()
			}, 1000);
		},
		methods: {
			// 获取token
			getToken() {
				let that = this
				uni.getStorage({
					key: 'loginData',
					success: function(res) {
						that.token = res.data.userInfo.appToken
						that.hrUuid = res.data.userInfo.uuid
						that.userInfo = res.data.userInfo
					}
				});
			},

			// 获取日常健康情况列表
			getList() {
				uni.showLoading({
					title: this.app.language.jzz,
				});
				let data = {
					hrUuid: this.hrUuid,
					token: this.token
				}
				console.log('data', data)
				getRcjk(data).then((res) => {
					uni.hideLoading();
					this.list = res.rows
					for (let i = 0; i < this.list.length; i++) {
						this.list[i].userName = this.userInfo.userName
						// 体温
						if (this.list[i].bodyTemperature >= 36 && this.list[i].bodyTemperature <= 37.8) {
							this.list[i].inspectionzt = this.app.language.hg
						} else {
							this.list[i].inspectionzt = this.app.language.bhg
						}
						// 心率
						if (this.list[i].heartRate >= '60' && this.list[i].heartRate <= '100') {
							this.list[i].heartRatezt = this.app.language.hg
						} else {
							this.list[i].heartRatezt = this.app.language.bhg
						}
						// 血氧饱和度
						if (this.list[i].bloodOxygenSaturation >= '95' && this.list[i].bloodOxygenSaturation <=
							'100') {
							this.list[i].bloodOxygenSaturationzt = this.app.language.hg
						} else {
							this.list[i].bloodOxygenSaturationzt = this.app.language.bhg
						}
						// 高压
						if (this.list[i].bloodPressure >= '90' && this.list[i].bloodPressure <= '140') {
							this.list[i].bloodPressurezt = this.app.language.hg
						} else {
							this.list[i].bloodPressurezt = this.app.language.bhg
						}
						// 低压
						if (this.list[i].dycount >= '60' && this.list[i].dycount <= '90') {
							this.list[i].dycountzt = this.app.language.hg
						} else {
							this.list[i].dycountzt = this.app.language.bhg
						}
						// 尿酸--暂时没有合格标准
						// if(this.list[i].uricAcid>='80'&&this.list[i].uricAcid<='140'){
						// 	this.list[i].inspectionzt = this.app.language.hg
						// }else{
						// 	this.list[i].inspectionzt = this.app.language.bhg
						// }
						// 血糖
						if (this.list[i].bloodSugar >= '3.9' && this.list[i].bloodSugar <= '7.8') {
							this.list[i].bloodSugarzt = this.app.language.hg
						} else {
							this.list[i].bloodSugarzt = this.app.language.bhg
						}
					}
					console.log('this.list', this.list)
				})
			},

			openPopup(item) {
				this.datainfo = item
				console.log('this.datainfo',this.datainfo)
				this.$refs.popup.open()
			},
			closePopup() {
			    this.$refs.popup.close()
			},

			// 新增民警日常健康
			add() {
				uni.navigateTo({
					url: '../user/rcHealthAdd'
				});
			}
		}
	}
</script>

<style>
	.container {
		padding: 0 10rpx;
	}

	.infoList {
		/* border-bottom: 1px dashed #ddd; */
		padding: 15rpx;
		font-size: 26rpx;
		box-shadow: 1px 1px 10rpx #ddd;
	}

	.box {
		display: flex;
	}

	.time {
		margin-left: auto;
	}

	.qua {
		color: blue;
		font-weight: 500;
		text-align: right;
		margin-top: 10rpx;
	}

	.NoQua {
		color: red;
		font-weight: 500;
		text-align: right;
		margin-top: 10rpx;
	}

	.addForm button {
		background-color: #2f8ef9;
		color: #fff;
		font-size: 28rpx;
		height: 60rpx;
		line-height: 60rpx;
		/* position: fixed;
		bottom: 0; */
		margin-top: 30rpx;
		width: 97%;
	}
	
	.box{
		border-bottom: 1px dashed #ddd;
		display: flex;
		padding: 15rpx 0;
	}
	
	.boxR{
		margin-left: auto;
		padding: 5rpx 31rpx;
		font-size: 22rpx;
		border-radius: 5rpx;
		border: 1px solid #59bea0;
		color: #59bea0;
		/* border-bottom: 1px solid #ddd; */
		padding: 5rpx 16rpx;
	}
	
	.boxR1{
		margin-left: auto;
		padding: 5rpx 31rpx;
		font-size: 22rpx;
		border-radius: 5rpx;
		border: 1px solid #d6605c;
		color: #d6605c;
		/* border-bottom: 1px solid #ddd; */
		padding: 5rpx 16rpx;
	}
	
	.popup-content{
		background-color: #fff;
		padding: 20rpx;
	}
	
	.vue-ref {
		padding-bottom: 0 !important;
	}
	
</style>